package com.wetest.uia2.stub.watcher;

import android.os.RemoteException;
import androidx.test.InstrumentationRegistry;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiSelector;
import com.wetest.uia2.stub.Log;

/* loaded from: classes5.dex */
public class PressKeysWatcher extends SelectorWatcher {
    private UiDevice device;
    private String[] keys;

    public PressKeysWatcher(UiSelector[] conditions, String[] keys) {
        super(conditions);
        this.keys = new String[0];
        this.device = null;
        this.keys = keys;
        this.device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    }

    @Override // com.wetest.uia2.stub.watcher.SelectorWatcher
    public void action() {
        Log.d("PressKeysWatcher triggered!");
        for (String str : this.keys) {
            String key = str.toLowerCase();
            if ("home".equals(key)) {
                this.device.pressHome();
            } else if ("back".equals(key)) {
                this.device.pressBack();
            } else if ("left".equals(key)) {
                this.device.pressDPadLeft();
            } else if ("right".equals(key)) {
                this.device.pressDPadRight();
            } else if ("up".equals(key)) {
                this.device.pressDPadUp();
            } else if ("down".equals(key)) {
                this.device.pressDPadDown();
            } else if ("center".equals(key)) {
                this.device.pressDPadCenter();
            } else if ("menu".equals(key)) {
                this.device.pressMenu();
            } else if ("search".equals(key)) {
                this.device.pressSearch();
            } else if ("enter".equals(key)) {
                this.device.pressEnter();
            } else if ("delete".equals(key) || "del".equals(key)) {
                this.device.pressDelete();
            } else if ("recent".equals(key)) {
                try {
                    this.device.pressRecentApps();
                } catch (RemoteException e) {
                    Log.d(e.getMessage());
                }
            } else if ("volume_up".equals(key)) {
                this.device.pressKeyCode(24);
            } else if ("volume_down".equals(key)) {
                this.device.pressKeyCode(25);
            } else if ("volume_mute".equals(key)) {
                this.device.pressKeyCode(164);
            } else if ("camera".equals(key)) {
                this.device.pressKeyCode(27);
            } else if ("power".equals(key)) {
                this.device.pressKeyCode(26);
            }
        }
    }
}